Skip to content

feat: Add methods for checked arithmetics to StakeHistoryEntry#394

Merged
joncinque merged 1 commit into
solana-program:mainfrom
vadorovsky:checked-arithmetics
May 20, 2026
Merged

feat: Add methods for checked arithmetics to StakeHistoryEntry#394
joncinque merged 1 commit into
solana-program:mainfrom
vadorovsky:checked-arithmetics

Conversation

@vadorovsky

Copy link
Copy Markdown
Contributor

The usage of existing std::ops::Add implementation triggers the arithmetic_side_effects clippy lint.

To allow addressing it, add the following methods to StakeHistoryEntry:

  • checked_add
  • wrapping_add
  • saturating_add

The usage of existing `std::ops::Add` implementation triggers the
`arithmetic_side_effects` clippy lint.

To allow addressing it, add the following methods to `StakeHistoryEntry`:

* `checked_add`
* `wrapping_add`
* `saturating_add`

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! We might want to consider deprecating the normal ops::Add implementation then

@joncinque joncinque merged commit 4300e71 into solana-program:main May 20, 2026
25 checks passed
@vadorovsky vadorovsky deleted the checked-arithmetics branch May 22, 2026 12:17
@vadorovsky

Copy link
Copy Markdown
Contributor Author

Makes sense to me! We might want to consider deprecating the normal ops::Add implementation then

Sadly, Rust doesn't support deprecating specific trait implementations or trait methods. But perhaps we could go for a more drastic measure and remove the implementation entirely?

@joncinque

Copy link
Copy Markdown
Contributor

Sadly, Rust doesn't support deprecating specific trait implementations or trait methods. But perhaps we could go for a more drastic measure and remove the implementation entirely?

Oh right of course, my mistake 😓 but yeah I'm fine with doing a full removal during a breaking change. Let's wait on it though.

Maybe we should add a comment to remember to remove it though. What do you think?

@vadorovsky

Copy link
Copy Markdown
Contributor Author

Maybe we should add a comment to remember to remove it though. What do you think?

Good idea, #406

grod220 pushed a commit to grod220/solana-sdk that referenced this pull request Jun 17, 2026
…ana-program/stake#394)

The usage of existing `std::ops::Add` implementation triggers the
`arithmetic_side_effects` clippy lint.

To allow addressing it, add the following methods to `StakeHistoryEntry`:

* `checked_add`
* `wrapping_add`
* `saturating_add`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants